package cn.yunhe.servlet;

/*
 * 郭慧广
 *
 * 商家分页
 *
 * 李非凡更改
 * */

import cn.yunhe.services.MerchantsFenYeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/MerchantsDataFenServlet")
public class MerchantsDataFenServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String pageIndex = request.getParameter("pageIndex");//得到当前页

        MerchantsFenYeService merchantsFenYeService = new MerchantsFenYeService();
        Map map = merchantsFenYeService.getMerchantsDataPage(pageIndex);

        //存入
        request.setAttribute("merchantsDataList", map.get("merchantsDataList"));
        request.setAttribute("pageNum", map.get("pageNum"));
        request.setAttribute("total", map.get("total"));


        request.getRequestDispatcher("list4.jsp").forward(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
